<head>
<meta http-equiv='content-type' content='text/html; charset=utf8' />
<title>jsGoo tests</title><link rel='stylesheet' href='main.css' type='text/css' />
<script type='text/javascript' src='jsgoo.js'></script>
<script type='text/javascript'>

function gen() {
        var rowtpl = _.tr(["{name}", "{city_name}", "{country_name}",  "{phone}", 
                            "{website}", _.a('open', '#', "openComp(this)")]);
        
        _.$into('main',
            _.wrap(
                _.tr(['Name', 'City', 'Country', 'Phone', 'Web', ''], 'th') +
                _.list(
                    _c.applyL(DATA.companies, {
                            website: function (v,i,n){ return v?_.wrap(v, 'a href="http://'+v+'"'):'' }
                    }), rowtpl ),
                'table class="data-table" cellspacing="0"'));
}

function openComp(el) { alert('open sesame'); return false; }

var DATA = {
    companies: [
                {"phone":"01/7808894","website":"www.refaktor.com","city_name":"Grosuplje","id":"1","name":"REFAKTOR d.o.o.","country_name":"Slovenia"},
                {"phone":"07/2834728","website":"www.gloriaana.com","city_name":"Sevnica","id":"2","name":"Gloria Ana d.o.o.","country_name":"Slovenia"},
                {"phone":"03/3453434","website":"www.somecomp.com","city_name":"Koper","id":"3","name":"Some Comp d.o.o.","country_name":"Slovenia"},
                {"phone":"02/2834728","website":"www.timeeaters.com","city_name":"Maribor","id":"4","name":"TimeEaters d.o.o.","country_name":"Slovenia"},
            ]
}
</script>
<body>
<div><a href="index.html">index</a> <a href="#" onclick="gen(); return false;">generate</a> 
<em></em></div>
<div id="main"></div>

<p>We generate the template for table and use it with <em>list</em> to generate the table in the 
same way as we would anything else. We use <em>applyL</em> to change the url to a link. </p> 
</body>
</html>